<?php
	session_start();
	function mysqlConnect_PHP(){
		include('../config/config.inc.php');	
		$db = mysql_connect($mysql_host, $mysql_user, $mysql_pass);
		$db_select = mysql_select_db($mysql_dbname, $db);	
	}
	if(($_POST['userid'] == $_SESSION['userid']) || ($_POST['wall'] == $_SESSION['userid']) || ($_POST['postUser'] == $_SESSION['userid']))
	{
		if(isset($_POST['postid']))
		{
			mysqlConnect_PHP();
			$query = 'DELETE FROM posts WHERE id="'.$_POST['postid'].'" AND wall="'.$_POST['wall'].'";';
			mysql_query($query);
			$query = 'DELETE FROM posts_comments WHERE postid="'.$_POST['postid'].'";';
			mysql_query($query);
		}
		elseif(isset($_POST['commentid']))
		{
			mysqlConnect_PHP();
			$query = 'DELETE FROM posts_comments WHERE id="'.$_POST['commentid'].'";';
			mysql_query($query);
		}
	}
?>